function init(){
	to = document.getElementById('max').value;	
	from = document.getElementById('min').value;	
	docno = document.getElementById('docno').value;
	
	to = to.format('Y-m-d');	
	from = from.format('Y-m-d');	
	getView(from,to,docno);
}


function addDate(val){
	max = document.getElementById('max').value;	
	min = document.getElementById('min').value;	
	docno = document.getElementById('docno').value;
	
	date = document.getElementById('sDateVal').value;	
	date = new Date(date);
	date.setDate(date.getDate() + (val));
	date = date.format('Y-m-d');
	
	if(  date >= min  && date <= max){
		getView(date,'',docno);
		getLv(date,'',docno);
		document.getElementById('sDateVal').value = date;
	}	
}

function getView(from,to,docno){	
	ColdFusion.navigate('viewRec.cfm?from='+from+'&to='+to+'&vw='+docno,'resView');	
}

function getLv(date,action,docno){	
	ColdFusion.navigate('leaveDtls.cfm?da='+date+'&vw='+docno,'lvView');	
}

function confirmDelete(fname){
	if ( confirm('Delete '+fname+'?') ) 
		return true;
	else 
		return false;
}
 
//Adding File
function autoSelectAll(){
	for (ncount=0; ncount < SSELSELECTEDEMPLOYEES.length; ncount++){
		SSELSELECTEDEMPLOYEES.options[ncount].selected = true;
	}
}

function compDate(){
	with(document.frmPMFFile){
		if(FROM.value !="" || TO.value !=""){
			if(Date.parse(FROM.value) > Date.parse(TO.value)){
				alert("Assessment date 'TO' must be on/later than "+FROM.value);	
				TO.value = "";
				FROM.value = "";
			}
		}
	}	
}

function Select_Employee()
{
with(document.frmPMFFile)
	{
	if(SSELAVAIALABLEMPLOYEES.style.display != 'none')
		var list = SSELAVAIALABLEMPLOYEES;
	else
		var list = SSELDIRECTEMPLOYEES;
		
	if (list.selectedIndex !== -1)
		{
		for (ncount=0; ncount < list.length; ncount++)
			{
			if (list[ncount].selected)
				{
				svalue = list.options[ncount].value;
				stext = list.options[ncount].text;
				optionselectedemployee = new Option(stext, svalue);
				SSELSELECTEDEMPLOYEES.options[SSELSELECTEDEMPLOYEES.length] = optionselectedemployee;	
				}
			}
		for (ncount=list.length-1; ncount >= 0; ncount--)
			{
			if (list[ncount].selected)
				{
				list.options[ncount] = null;
				}
			}
		
		}

	}
}
	
		
		
function Remove_Employee()
{
	with(document.frmPMFFile)
	{
	if(SSELAVAIALABLEMPLOYEES.style.display != 'none')
		var list = SSELAVAIALABLEMPLOYEES;
	else
		var list = SSELDIRECTEMPLOYEES;
		
	if(SSELSELECTEDEMPLOYEES.selectedIndex !== -1)
		{
		for (ncount=0; ncount < SSELSELECTEDEMPLOYEES.length; ncount++)
			{
			if (SSELSELECTEDEMPLOYEES[ncount].selected)
				{
				svalue = SSELSELECTEDEMPLOYEES.options[ncount].value;
				stext = SSELSELECTEDEMPLOYEES.options[ncount].text;
				optionremovedemployee = new Option(stext, svalue);
				list.options[list.length] = optionremovedemployee;	
				}
			}
		for (ncount=SSELSELECTEDEMPLOYEES.length-1; ncount >= 0; ncount--)
			{
			if (SSELSELECTEDEMPLOYEES[ncount].selected)
				{
				SSELSELECTEDEMPLOYEES.options[ncount] = null;
				}
			}
		}
	}
}
		
function Select_All_Employee()
{
	with(document.frmPMFFile)
	{
		if(SSELAVAIALABLEMPLOYEES.style.display != 'none')
			var list = SSELAVAIALABLEMPLOYEES;
		else
			var list = SSELDIRECTEMPLOYEES;
			
		for (ncount=0; ncount < list.length; ncount++)
			{			
			svalue = list.options[ncount].value;
			stext = list.options[ncount].text;
			optionselectedemployee = new Option(stext, svalue);
			SSELSELECTEDEMPLOYEES.options[SSELSELECTEDEMPLOYEES.length] = optionselectedemployee;	
			}
		for (ncount=list.length-1; ncount >= 0; ncount--)
			{
			list.options[ncount] = null;
			}
	}
}
		
function Remove_All_Employee()
{
	with(document.frmPMFFile)
	{
		if(SSELAVAIALABLEMPLOYEES.style.display != 'none')
			var list = SSELAVAIALABLEMPLOYEES;
		else
			var list = SSELDIRECTEMPLOYEES;
		for (ncount=0; ncount < SSELSELECTEDEMPLOYEES.length; ncount++)
			{
			svalue = SSELSELECTEDEMPLOYEES.options[ncount].value;
			stext = SSELSELECTEDEMPLOYEES.options[ncount].text;
			optionremovedemployee = new Option(stext, svalue);
			list.options[list.length] = optionremovedemployee;	
			}
		for (ncount=SSELSELECTEDEMPLOYEES.length-1; ncount >= 0; ncount--)
			{
			SSELSELECTEDEMPLOYEES.options[ncount] = null;
			}
	}
}

function showLookUp(){
	wtype = document.getElementById('wtype').value;
	if( wtype == 'CINWSSUBSKED' )
		LookupWSPATTERN();
	else
		LookupWSSKED();
	
		
}
function LookupWSPATTERN(fld1,fld2,fld3,form) 
	{	
		open("../../common/poplookup.cfm" +
		"?tl=C" +
		"&tn=CLKWSPATTERN" +
		"&fn="+fld1+//+","+fld2+","+fld3+
		"&desc="+fld2+","+fld3+
 		"&rf="+
		"&frm="+form+
		"&autosubmit=N" +
		"&fldprop=PATTERNCODE~PATTERNCODE~ftstring,DESCRIPTION~DESCRIPTION~ftstring,CATEGORY~CATEGORY~ftstring" +
		"&nonull=Y" +
		"&fldfn=PATTERNCODE" +
		"&flddesc=DESCRIPTION,CATEGORY",
		 "LookupWindow", "width=660,height=330,ScrollBars=Yes,Resizable=Yes");
	}
function LookupWSSKED() 
	{ 
		open("../../common/poplookup.cfm" +
		"?tl=C" +
		"&tn=CLKWORKSKED" +
		"&fn=PATTERN,CATEGORY" +
		"&desc=PATTERN,CATEGORY" +
 		"&rf=" +
		"&frm=frmPMFFile" +
		"&autosubmit=N" +
		"&fldprop=WORKSKEDCODE~WORKSKEDCODE~ftstring,CATEGORY~CATEGORY~ftstring,POLICYCODE~POLICYCODE~ftstring,TIME-IN~TIMEIN~ftstring,TIME-OUT~TIMEOUT~ftstring" +
		"&nonull=Y" +
		"&fldfn=WORKSKEDCODE" +
		"&flddesc=WORKSKEDCODE,CATEGORY&fldFilter=TYPE<>,&fldVal=PERMANENT",
		 "LookupWindow", "width=660,height=330,ScrollBars=Yes,Resizable=Yes");
	}
	

function onShow(){	
  window.setTimeout(
	  function Tick() {
	  document.getElementById('err').innerHTML='';
  }, 4000);
}

function showPop(BTN)
{

	hidePop();
	document.getElementById(BTN).style.display = "block";
	
	
	
	

}

function hidePop()
{
   length = document.getElementsByClassName('popUp').length;
	for( i=0; i<length; i++)
		document.getElementsByClassName('popUp').item(i).style.display="none";
	
}

function clearFields(){

	with(document.frmPMFFile){
		SSELAVAIALABLEMPLOYEES.options.length = 0;
		SSELSELECTEDEMPLOYEES.options.length = 0;
	}
}


function showHdr(id){
	bdy = id+"body";
	hdr = id+"hdr";
	document.getElementById(bdy).style.display ='none';
	document.getElementById(hdr).style.display ='block';
}

function showBody(id){
	bdy = id+"body";
	hdr = id+"hdr";
	document.getElementById(bdy).style.display ='block';
	document.getElementById(hdr).style.display ='none';
	
}

